{% extends 'base.html' %}
{#页面标题#}
{%block title%}my site{%endblock%}

{% block nav_blog_active%}active{% endblock %}>

{% load staticfiles %}
{%block header_extends%}
    <link rel="stylesheet" href="{%static 'blog/blog.css'%}">
{%endblock%}

{#页面内容#}
{%block content%}
    <div class="container">
        <div class = "container">
            <div class="row">
                <div class="col-xs-12 col-sm-8 col-md-9 col-lg-10">
                    <div class="panel panel-default">
                        <div class="panel-heading">{%block blog_list_title%}博客列表&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;一共有{{views_page_of_blogs.paginator.count}}篇博客 {%endblock%}另一种方法{{views_blogs_count}}篇博客</div>
                        <div class="panel-body"> 
                            
                            {%for x in views_blogs %}
                                <div class = "blog">
                                    <h3><a href="{%url 'urls_blog_detail' x.id%}">{{ x.title }}</a></h3>
                                    <p class="blog-info">
                                        <span class="glyphicon glyphicon-tag" aria-hidden="true"></span><a href="{%url 'xxx' x.pk%}">{{x.blog_type}}</a>&nbsp;&nbsp;
                                        发表日期：{{x.created_time|date:'Y-m-d'}}
                                        阅读({{x.get_read_num}})
                                        
                                    </p>
                                    <p>{{ x.content|striptags|truncatechars:120 }}</p>
                                </div> 
                            {%empty%}
                                <div class= "blog" >
                                    <h3>--暂时没有，下次再来吧！--</h3>
                                </div>
                             {%endfor%}
                            
                            
                        </div>
                    </div> 
                    <div class = "paginator">
                        <ul class="pagination">
                            {#上一页#}
                            <li>
                                {%if views_page_of_blogs.has_previous%}
                                    <a href="?page={{views_page_of_blogs.previous_page_number}}" aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                {%else%}
                                    <span aria-hidden="true">&laquo;</span>
                                {%endif%}
                            
                              
                            </li>
                            {#全部页码#}
                            {%for page_num in page_range%}
                                {%if page_num == views_page_of_blogs.number%}
                                    <li class="active"><span>{{page_num}}</span></li>
                                {%else%}
                                    {%if page_num == '...'%}
                                        <li><span>{{page_num}}</span></li>
                                    {%else%}
                                        <li><a href="?page={{page_num}}">{{page_num}}</a></li>
                                    {%endif%}
                                {%endif%}
                                
                                
                                
                            {%endfor%}
                            {#下一页#}

                            <li>
                                {%if views_page_of_blogs.has_next%}
                                    <a href="?page={{views_page_of_blogs.next_page_number}}" aria-label="Next">
                                        <span aria-hidden="true">&raquo;</span>
                                    </a>
                                {%else%}
                                    <span aria-hidden="true">&raquo;</span>
                                {%endif%}
                            </li>
                        </ul>

                    <p>    
                        共有{{views_page_of_blogs.paginator.count}}篇博客，当前第{{views_page_of_blogs.number}}页，共{{views_page_of_blogs.paginator.num_pages}}页
                    </p>
                        
                    </div>
                </div>
                
                
                <div class = "hidden-xs col-sm-4 col-md-3 col-lg-2">
                    <div class="panel panel-default">
                        <div class="panel-heading">博客分类</div>
                        <div class="panel-body">
                            <ul class="blog-types">
                                {% for x in views_blog_types %}
                                    <li>
                                        <a href="{%url 'xxx' x.pk%}">
                                            {{x.type_name}} ({{x.blog_count}})
                                        </a>
                                    </li>
                                {% empty %}
                                    <li>暂无分类</li>
                                {% endfor %}
                            </ul>
                        </div>
                    </div>	
                    <div class="panel panel-default">
                        <div class = "panel-heading">日期归档</div>
                        <div class = "panel-body">
                            <ul>
                                {% for xx,yy in views_blog_dates.items %}
                                    <li>
                                        <a href="{%url 'xxx_date' xx.year xx.month%}">
                                            {{xx|date:"Y年m月"}} ({{yy}})
                                        </a>
                                    </li>
                                {% endfor %}
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>





{%endblock%}

<!--
<!DOCTYPE html>
<html>
<head>
    <meta charset='UTF-8'>
    <title>我的网站</title>
    
</head>
<body>

    <div>
        <h3>个人博客网站首页</h3>
    </div>
    <hr>
    
    {%for x in views_blogs%}
        <a href="{%url 'urls_blog_detail' x.id%}">
            <h3>{{ x.title }}</h3>
        </a>
        <p>{{ x.content|truncatechars:30 }}</p>
    {%empty%}
        <p>--暂时没有，下次再来吧！--</p>
    {%endfor%}
    
    <p>一共有{{views_blogs|length}}篇博客 另一种方法{{views_blogs_count}}</p>{{views_blogs_count}}


</body>

</html>
-->